﻿using System;
using System.Configuration;
using System.Security.Cryptography.X509Certificates;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using More.Application.BaseModel;
using More.Application.Entity.Repository;
using Rules112014;

namespace More.UnitTests
{
    [TestClass]
    public class LookupTests
    {
        private IRatingEngineTableRepository _repository;
        [TestInitialize]
        public void Initialize()
        {
            _repository =
                new SqlLookupTableRepository(
                    new SqlLookupTableContext(
                        ConfigurationManager.ConnectionStrings["Dev.IsoDb"].ConnectionString),
                    new DateTime(2015, 10, 1), false);
        }


        [TestMethod]
        public void GetLookupTable()
        {
            const string tableToMatch = "PrivatePassengerOtherThanCollisionDeductibleRelativity";
            const string tableId = "6C84C211-032B-4531-A33B-A083B8A4406B";

            const double expectedLookupValue = -0.41;
            var table = _repository.GetLookupTable(tableId);
            var value = Convert.ToDouble(table.Lookup("Factor", "Full Coverage"));
            Assert.AreEqual(expectedLookupValue,value);
            Assert.IsNotNull(table);
            Assert.AreEqual(tableToMatch, table.Name);
        }
    }
}
